﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSLS05
    {
        public TSLS05()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            MV = new VLIEFKO();
            this.DataContext = MV; 
            InitializeComponent();
         }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KEY = "";
                LIEFBED = "";
                ZAHLBED = "";
                VSPED = "";
                SART = "";
            }
            else
            {
                KEY =  dwMaster["LSKKONDSL"].ToString().PadRight(4);
                LIEFBED = dwMaster["LSKLIEFBED"].ToString();
                ZAHLBED = dwMaster["LSKZAHLBED"].ToString();
                VSPED = dwMaster["LSKSPEDSL"].ToString();
                SART = dwMaster["LSKVERSART"].ToString();
            }
        }

        public override void OnLIEFNRChg(string value)
        {
            TBMain.Clear();
            if (value.Trim().Length < 8)
            { //00000000
                return;
            }
            dwData = TBMain.NewRow();
            dwData["LSKMANDANT"] = app.Mandant;
            dwData["LSKLIEFNR"] = " AND LSKLIEFNR='"+value.Substring(0,8)+"'";
            SResult = TMV.QueryLIEFKO(dwData, 1);
            MergeData(SResult, false); 
        }
        public override void LOADBYAUF()
        {
            Locate("KEY", ORDERNUM); 
        }
   
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                OnLIEFNRChg(LIEFNR);
            }
            else
            {
                VICC_WFEVENTS.SVWF.LS02(this.RUNID);
            }
            base.ManageCommand(sender, e);
        }

       
    }
}
